dojo.provide("miaigo.model.sgf.properties.Number");

dojo.require("miaigo.model.sgf.SGFProperty");

/*
 * Properties handled:
 *   FF, GM, HA, MN, OB, OW, PM, ST, SZ
 * Currently handled:
 *   SZ
 */

dojo.declare(
    "miaigo.model.sgf.properties.Number",
    [miaigo.model.sgf.SGFProperty],
    {
	onApply: function(game)
	{
	    var value = this.getValue();
	    if (!isNaN(value))
	    {
		switch (this.getID())
		{
		case "SZ":
		    game.setBoardSize(this.getValue());
		    break;
		case "GM":
		    if (1 != this.getValue())
		    {
			console.error("Not SGF for Go");
		    }
		    break;
		}
	    }
	},

	getValue: function(/*integer (optional)*/index)
	{
	    var value = this.getRawValue();
	    var colonIndex = value.indexOf(":");
	  
	    if (0 < colonIndex)
	    {
		value = value.substring(0, colonIndex);
	    }

	    return new Number(value);
	}
    });